#include "Comm.hpp"
#include "Fifo.hpp"

int main()
{
    key_t key = GetShmKey();
    cout << " key : " << key << endl;
    // sleep(1);

    int shmid = GetShm(key, defaultsize);
    cout << " shmid : " << shmid << endl;
    // sleep(1);

    char* addr = (char*)ShmAttach(shmid);
    cout <<"Attach shm succuss, addr: " << ToHex((uint64_t)addr) << endl;

    // 用管道来辅助形成
    memset(addr, 0, defaultsize);
    Sync syn;
    syn.OpenWriteOrDie();

    for(char c = 'A'; c <= 'Z'; c++)
    {
        addr[c-'A'] = c; // 可以直接向共享内存写入，相当于malloc的一段空间，当成是数组来用
        sleep(1);
        syn.WakeUp();
    }
    return 0;
}